<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>登录</title>
</head>
<body>
<form id="form" method="post">
	<h2>登录页面</h2>
	<table>
		<tr>
			<th>用户名：</th>
			<th><input type="text" name="username" id="username"></th>
			<th>密码：</th>
			<th><input type="password" name="password" id="password"></th>
			<th><input type="button" value="登录" id="active"></th>
		</tr>
	</table>
</form>
<script src="/static/news/js/jquery-1.12.4.min.js"></script>
<script>

	$("#active").click(function () {
		formdata = new FormData($("#form")[0]);
		$.ajax({
			url:"/login",
			method:"post",
			data:formdata,
			processData:false,
			contentType:false,
			success:function (formdata) {
				alert(formdata.msg);
				window.location.href="/goodslist"; //重定向到此网页
				console.log(formdata)
            },
			error:function (error, formdata) {
				alert(formdata.msg);
				console.log(error)
            }
		})
    })

</script>
</body>
</html>